/******************************************************************************
 * The contents of this file are subject to the   JDI License  Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Initial Developer of the Original Code is 陈慧然. Portions created by 
 * 陈慧然 are Copyright 陈慧然.
 * All Rights Reserved.
 *
 *              Contact john_holen@163.com for licensing alternatives.
 *
 *****************************************************************************/


package org.peony.models;

import org.peony.exceptions.ConfigException;
import org.peony.tools.PeonyLogger;

/**
 *  
 *
 *  @author     陈慧然
 *  @version    Id: MApplicationConfig.java, v 0.000 2008-6-15 下午06:58:35 陈慧然 Exp
 */
public class MApplicationConfig {
	private static int dbmsType;
	private static String jdbcDriver;
	private static String dbUser;
	private static String dbPassword;
	private static String dbUrl;
	private static int maxConn;
	private static int minConn;
	
	private MApplicationConfig config;
	
	private MApplicationConfig(){	}
	
	public static synchronized void setModel(int dbmsType, String jdbcDriver, 
			String dbUser, String dbPassword, String dbUrl,
			int maxConn, int minConn) {
		if(maxConn <= 0 || minConn <= 0 || maxConn < minConn)
			throw new ConfigException(ConfigException.MAXORMINCONNISNOTAVAILABLE);
		MApplicationConfig.dbmsType = dbmsType;
		MApplicationConfig.jdbcDriver = jdbcDriver;
		MApplicationConfig.dbUser = dbUser;
		MApplicationConfig.dbPassword = dbPassword;
		MApplicationConfig.dbUrl = dbUrl;
		MApplicationConfig.maxConn = maxConn;
		MApplicationConfig.minConn = minConn;
	}
	
	public static int getDbmsType() {
		return dbmsType;
	}

	public static String getJdbcDriver() {
		return jdbcDriver;
	}

	public static String getDbUser() {
		return dbUser;
	}

	public static String getDbPassword() {
		return dbPassword;
	}

	public static String getDbUrl() {
		return dbUrl;
	}

	public static int getMaxConn() {
		return maxConn;
	}

	public static int getMinConn() {
		return minConn;
	}
}
